package com.gitee.theskyzero.boot.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(TestConfigurationProperties.class)
public class TestConfiguration {

    @Autowired
    TestConfigurationProperties properties;

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnClass(TestBean.class)
    TestBean testBean() {
        TestBean bean = new TestBean();
        bean.setProperties(properties);
        return bean;
    }

}
